package com.xbongbong.saas.enums;

import lombok.Getter;
import java.util.Objects;

/**
 * 评分脚本操作行为
 * @author chunyang.qin
 * @version v1.0
 * @date 2020/11/30 21:47
 * @since v1.0
 */
@Getter
public enum ScoreScriptOperationTypeEnum {
    /**
     * 脚本正常触发
     */
    NORMAL(0),
    /**
     * 修复(脚本触发失败等)
     */
    REPAIR(1),

    UNKNOWN(404),
    ;
    private Integer code;

    ScoreScriptOperationTypeEnum(Integer code) {
        this.code = code;
    }


    /**
     * 通过枚举 code 获得枚举
     *
     * @param code 枚举Code
     *
     * @return ScoreScriptOperationTypeEnum
     */
    public static ScoreScriptOperationTypeEnum getByCode(Integer code) {
        for (ScoreScriptOperationTypeEnum cacheCode : values()) {
            if (Objects.equals(code, cacheCode.getCode())) {
                return cacheCode;
            }
        }
        return UNKNOWN;
    }
}
